<?php
require_once('conn.inc.php'); 
@$phone 	=	 	$_POST["phone"]; 
@$password	=		md5(md5($_POST["password"])); 
@$regdate	=		time();							//注册时间
$conn=mysql_connect($db_host,$db_user,$db_pwd);
mysql_query("set names 'utf8'");
mysql_select_db($db_name);

if ($phone == null || $password == null) {
	$rc = array('code'=>-1);							//表单内容获取失败，或者用户名密码不能为空
	echo json_encode($rc);
}else{
	$find = "select*from member where phone='$phone'";
	$result = mysql_query($find);
	$num_rows = mysql_num_rows($result);
	if ($num_rows >= 1) {
		$rc = array('code'=>0);						//表单信息重复
		echo json_encode($rc);
	}else{
		$sql = "insert into member (phone,password,regdate) values ('$phone','$password','$regdate')";
		$result = mysql_query($sql);
		$rc = mysql_affected_rows();
		if ($rc==1) {
			$rc = array('code'=>1);
			echo json_encode($rc);					//注册成功                                                                
		}else {
			$rc = array('code'=>2);
			echo json_encode($rc);					//注册成功
		}
		mysql_close();
	}
}